import { Router } from 'hyper-express';
import requireUser from '../../../middlewares/auth/requireUser';
import cache from '../../../middlewares/cache';
import rowLevelPermission from '../../../middlewares/auth/rowLevelPermission';
//#region AutoCreateCode
import { uctooPermissionsController } from '../../../controllers';
const uctoopermissionsRouter = new Router();
const permissionsController = new uctooPermissionsController();

uctoopermissionsRouter.post('/add', requireUser, permissionsController.add);
uctoopermissionsRouter.post('/edit', requireUser, rowLevelPermission('uctoo/permissions'), permissionsController.edit);
uctoopermissionsRouter.post('/del', requireUser, rowLevelPermission('uctoo/permissions'), permissionsController.delete);

//For getting permissions with permission control
uctoopermissionsRouter.get('/:id', requireUser,  rowLevelPermission('uctoo/permissions'), permissionsController.getSingle);
uctoopermissionsRouter.get('/:limit/:page', requireUser,  rowLevelPermission('uctoo/permissions'), permissionsController.getMany);
uctoopermissionsRouter.get('/:limit/:page/:skip', requireUser,  rowLevelPermission('uctoo/permissions'), permissionsController.getMany);

//#endregion AutoCreateCode
uctoopermissionsRouter.post('/menu/all',  permissionsController.menuAll);
uctoopermissionsRouter.post('/menu/userMenuAll',  permissionsController.getUserPermissions);
uctoopermissionsRouter.post('/loadMenuFromDb',  permissionsController.loadMenuFromDb);
uctoopermissionsRouter.post('/loadRouteFromApp',  permissionsController.loadRouteFromApp);
uctoopermissionsRouter.post('/getGroupPermissions',  permissionsController.getGroupPermissions);
uctoopermissionsRouter.post('/getCheckedGroupPermissions',  permissionsController.getCheckedGroupPermissions);
export default uctoopermissionsRouter;
